class Solution {
    public int minimumOperations(int[][] grid) {
        if(grid.length <= 1){
            return 0;
        }
        int sum = 0;
        for(int i = 1;i < grid.length;i ++){
            for(int j = 0;j < grid[0].length;j ++){
                if(grid[i][j] <= grid[i - 1][j]){
                    sum += grid[i - 1][j] - grid[i][j] + 1;
                    grid[i][j] = grid[i - 1][j] + 1;
                }
            }
        }
        return sum;
    }
}